/**
 * @param {string} s
 * @return {boolean}
 */
 var isValid = function(s) {
    let n = s.length
    let m = new Map([
        ['(',')'],
        ['{','}'],
        ['[',']']
    ])
    let stack = []
   
    for(let i = 0;i<n;i++){
        if(m.has(s[i])){
            stack.push(s[i])
        }else{
            if(m.get(stack.pop())==s[i]) continue
            else return false
        }
    }
   
    return stack.length===0?true:false
};
//console.log(isValid("()[]{}"));
